package com.pimwi.view.popup
{
  import com.pimwi.dp.GroupDP;
  import com.pimwi.vo.request.SaveContactRequest;

  public class EditContactPopUp extends ContactPopUp
  {
    public function EditContactPopUp()
    {
      super();
      title = "Modifier un contact";
    }

    protected override function applyButtonClickHandler():void
    {
      contactDP.firstName = firstNameInput.text;
      contactDP.lastName = lastNameInput.text;
      contactDP.address = addressInput.text;
      contactDP.city = cityInput.text;
      contactDP.email = emailInput.text;
      contactDP.phone = phoneInput.text;
      contactDP.groupId = (groupCombo.selectedItem as GroupDP).id;

      var request:SaveContactRequest = new SaveContactRequest();
      request.contact = contactDP.contact;
      request.userId = locator.userDP.id;

      locator.contactService.saveContact(request);

      closePopUp();
    }

  }
}